package com.xuecheng.test.rabbitmq;

import com.xuecheng.test.rabbitmq.config.RabbitMQConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
public class Producer05_topics_SpringBoot {
    // 使用RabbitMQTemplate发送消息
    @Autowired
    RabbitTemplate rabbitTemplate;

    @Test
    public void testSendEmail() {
        String message = "发送email";
        /**
         * 参数
         * 1: 路由器
         * 2: routingKey
         * 3: 消息内容
         */
        rabbitTemplate.convertAndSend(RabbitMQConfig.EXCHANGE_TOPICS_INFORM, "inform.email", message);
        System.out.println("发送完成");
    }

}
